<?php 

namespace Admin\Controller;
use Think\Controller;


class LoginController extends CommonController
{
	
	public function index(){

		$this->assign('title','后台登录');
		$this->display();
	}

	public function checkdata(){

		$data = I('post.');
		//var_dump($data);exit;

		$res = M('auth_group_access')->where(['username'=>$data['username'],'password'=>md5($data['pass'])])->find();

		if($res){
			$_SESSION['aid'] = $res['uid'];
			$_SESSION['username'] = $data['username'];
			$_SESSION['password'] = md5($data['pass']);
			$this->ajaxReturn(["error"=>0,"info"=>'登录成功']);
		}else{
			$this->ajaxReturn(["error"=>1,"info"=>'账号或密码错误']);
		}
	}

	public function logout(){
		session_unset();
		session_destroy();
		$this->assign('title','退出登录');
		$this->success('退出成功',U('admin/login/index'),3);
	}

}

 ?>